package com.example.restaurantclient.Activity.Shop;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.bumptech.glide.Glide;
import com.example.restaurantclient.ConfigUtil.ConfigUtil;
import com.example.restaurantclient.R;


public class ShopShop extends AppCompatActivity {
    private ImageView imageView;
    private ImageView imageView1;
    private TextView name;
    private TextView price;
    private TextView amount;
    private TextView no;
    private TextView size;
    private TextView material;
    private TextView explain;
    private TextView delivery;

    private Button commute;

    private int id;
    private String pname;
    private int pprice;
    private int pamount;
    private String pno;
    private String psize;
    private String pmaterial;
    private String pexplain;
    private String pdelivery;
    private int pintegral;
    private String picture;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shop_item);
        imageView = findViewById(R.id.img_shop);
        imageView1 = findViewById(R.id.cookie_details_xiaphoto);

        name = findViewById(R.id.tv_goods);
        price = findViewById(R.id.tv_num);
        amount = findViewById(R.id.cookie_details_amount);
        no = findViewById(R.id.tv_no);
        size = findViewById(R.id.tv_size);
        material = findViewById(R.id.tv_material);
        explain = findViewById(R.id.tv_explain);
        delivery = findViewById(R.id.tv_delivery);
        commute = findViewById(R.id.commute);

        Intent intent = getIntent();
        id = intent.getIntExtra("id",0);
        pname = intent.getStringExtra("name");
        pprice = intent.getIntExtra("price",0);
        pamount = intent.getIntExtra("amount",0);
        pno = intent.getStringExtra("no");
        psize = intent.getStringExtra("size");
        pmaterial = intent.getStringExtra("material");
        pexplain = intent.getStringExtra("explain");
        pdelivery = intent.getStringExtra("delivery");
        pintegral = intent.getIntExtra("integral",0);
        picture = intent.getStringExtra("picture");

        name.setText(pname);
        price.setText(pprice+"");
        amount.setText(pamount+"");
        no.setText(pno);
        size.setText(psize);
        material.setText(pmaterial);
        explain.setText(pexplain);
        delivery.setText(pdelivery);
        Glide.with(this)
                .load(picture)
                .into(imageView);
        Glide.with(this)
                .load(picture)
                .into(imageView1);

        commute.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent1 = new Intent(ShopShop.this,ConfirmActivity.class);
                intent1.putExtra("id",id);
                intent1.putExtra("name",pname);
                intent1.putExtra("integral",pintegral);
                intent1.putExtra("amount",pamount);
                intent1.putExtra("picture",picture);
                startActivity(intent1);
            }
        });
    }

    @Override
    protected void onPause() {
        super.onPause();
        finish();
    }
}
